FEAT: Complex data type support- uniqueidentifier#236
Merged
gargsaumya merged 8 commits intomainfrom Sep 24, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive support for Python's uuid.UUID type when working with SQL Server UNIQUEIDENTIFIER columns. It enables native UUID handling for both parameter binding and result retrieval.
- Added parameter mapping for UUID objects to SQL_GUID type in cursor.py
- Implemented UUID byte conversion and marshaling in the C++ binding layer
- Enhanced result fetching to return Python UUID objects instead of raw bytes
- Added comprehensive test coverage for UUID operations including NULL handling
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| mssql_python/cursor.py | Maps UUID parameters to SQL_GUID type and converts UUID objects to bytes |
| mssql_python/pybind/ddbc_bindings.cpp | Implements UUID parameter binding and result conversion with proper byte order handling |
| tests/test_004_cursor.py | Adds test cases for UUID insertion, retrieval, and NULL value handling |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
75f7a57 to
e9aa833
Compare
1b059c3 to
c03b72b
Compare
51842bf to
b7fceaa
Compare
sumitmsft
reviewed
Sep 19, 2025
sumitmsft
reviewed
Sep 19, 2025
sumitmsft
reviewed
Sep 19, 2025
sumitmsft
reviewed
Sep 19, 2025
sumitmsft
reviewed
Sep 19, 2025
7b10bf4 to
32e7d04
Compare
sumitmsft
approved these changes
Sep 23, 2025
bewithgaurav
approved these changes
Sep 24, 2025
This was referenced Sep 24, 2025
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work Item / Issue Reference
Summary
This pull request adds comprehensive support for Python's
uuid.UUIDtype when interacting with SQL ServerUNIQUEIDENTIFIERcolumns. It updates both the parameter binding and result retrieval logic to handle UUIDs as native Python objects, ensuring correct type mapping, byte order, and conversion in both directions. Additionally, new tests are introduced to verify correct insertion and retrieval of UUID values, including edge cases withNone.UUID/UNIQUEIDENTIFIER Support Improvements:
mssql_python/cursor.pyto map Pythonuuid.UUIDobjects to the correct SQL types and convert them to raw bytes before sending to SQL Server. [1] [2]mssql_python/pybind/ddbc_bindings.cpp) to correctly marshal UUIDs between Python and SQL Server, including proper byte order conversion and error handling for incorrect UUID sizes.UNIQUEIDENTIFIERcolumns back into Pythonuuid.UUIDobjects, both for single-row and batch fetches, and to handleNULLvalues gracefully. [1] [2]Testing Enhancements:
tests/test_004_cursor.pyto verify correct insertion, retrieval, and handling ofNonevalues in UUID columns, as well as round-trip integrity for multiple UUIDs. [1] [2]